package org.dtrd.modules.device.entity.po;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;

import java.util.Date;

import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import org.dtrd.modules.device.entity.bean.DeviceDetail;

import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;


/**
 *
 * @author xiao
 * @since 2022-01-11
 */
@Data
@TableName("dtrd_ent_rd_device")
public class DtrdEntRdDevice {

    @TableId(value = "data_id", type = IdType.ASSIGN_UUID)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private String dataId;

    @TableField("is_del")
    @TableLogic
    private Integer isDel;

    @TableField("create_time")
    private Date createTime;

    /**
     * 用户id
     */
    @TableField("user_id")
    private Integer userId;

    /**
     * 设备序列号
     */
    @TableField("device_sn")
    private String deviceSn;

    /**
     * 绑定状态  1已绑定 2 解绑
     */
    @TableField("device_bind_state")
    private Integer deviceBindState;

    @TableField("device_imsi")
    private String deviceImsi;

    @TableField("device_imei")
    private String deviceImei;

    /**
     * 设备品牌  1小糖医  2 爱奥乐  3 微策
     */
    @TableField("device_brand")
    private Integer deviceBrand;

    /**
     * 设备种类  1 血糖仪 2 血压计
     */
    @TableField("device_category")
    private Integer deviceCategory;

    /**
     * 设备激活时间
     */
    @TableField("activate_time")
    private Date activateTime;

    public DtrdEntRdDevice init() {
        isDel = 0;
        createTime = new Date();
        return this;
    }

    public DtrdEntRdDevice parseFromDto(DeviceDetail dto) {
        dataId = dto.getDataId();
        userId = dto.getUserId();
        deviceSn = dto.getDeviceSn();
        deviceBindState = dto.getDeviceBindState();
        deviceImsi = dto.getDeviceImsi();
        deviceImei = dto.getDeviceImei();
        deviceCategory = dto.getDeviceCategory();
        activateTime = dto.getActivateTime();
        return this;
    }


}
